package org.springframework.prospring.ticket.service.impl;

import org.springframework.prospring.ticket.service.ClubManager;
import org.springframework.prospring.ticket.service.FieldManager;
import org.springframework.prospring.ticket.dao.ClubDAO;
import org.springframework.prospring.ticket.dao.FieldDAO;
import org.springframework.prospring.ticket.domain.Club;
import org.springframework.prospring.ticket.domain.Field;
import org.springframework.prospring.ticket.domain.Turn;
import org.springframework.prospring.ticket.domain.user.User;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.Collection;
import java.util.Date;
import java.sql.Timestamp;

public class FieldManagerImpl implements FieldManager {
    private static Log logger = LogFactory.getLog(FieldManagerImpl.class);
    private FieldDAO dao;

    public FieldManagerImpl() {
        super();
        if (logger.isDebugEnabled()) {
            logger.debug("in FieldManagerImpl Constructor");
        }
    }

    public void setFieldDAO(FieldDAO dao) {
        if (logger.isDebugEnabled()) {
            logger.debug("setting FieldDAO: " + dao);
        }

        this.dao = dao;
    }

    public Field findField(Long fieldId) {
        if (logger.isDebugEnabled()) {
            logger.debug("finding Field id: "+fieldId);
        }
        Field field = dao.findField(fieldId);

        if (field == null) {
            logger.warn("Field id '" + fieldId + "' not found in database.");
        }

        return field;
    }

    public Field saveField(Field field) throws Exception {
        if (logger.isDebugEnabled()) {
            logger.debug("saving Field: " + field);
        }

        dao.saveField(field);

        return field;
    }


}
